/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.utils.easing
{
	internal class TrigonometricEasingImpl extends Easing implements IEasing
	{
		protected var _x0:Number;
		protected var _vx:Number;
		private var _end:Number;
		protected var _Asin:Array = new Array();
		public function TrigonometricEasingImpl(start:Number, end:Number, count:uint) {
			updateCoreParams(start, end, count);
		}
		
		protected function updateCoreParams(start:Number, end:Number, count:uint):void {
			frame = count;
			_x0 = start;
			_end = end;
			_vx = (end-start) / (frame);
			initialize();
		}

		public function forward():Number {
			var pp:Number;
			if (isMoving()) {
				pos++;
			}
			if (isMoving()) {
				pp = _x0 + pos * _vx - _Asin[pos];
			} else {
				pp = _end;
			}
			return pp;
		}
	}
	
}